package com.common.service.impl;

import com.common.dao.SimpleDao;
import com.common.entity.SupperEntity;
import com.common.model.SupperModel;
import com.common.mysql.SearchPageResult;
import com.common.mysql.Where;
import com.common.repository.SimpleRepository;

import java.util.List;

/**
 * Description: 简易service实现类，简化了repository和dao层
 * Date: 2024/1/12 23:38
 */
public class SimpleServiceImpl<I, M extends SupperModel<I>, E extends SupperEntity<I>> extends BaseServiceImpl<I, M, E, SimpleRepository<I, E>, SimpleDao<I, E>> {
    @Override
    public List<M> search(Where where) {
        repository.setEntityClass(getEntityClass());
        return super.search(where);
    }

    @Override
    public List<M> searchAll() {
        repository.setEntityClass(getEntityClass());
        return super.searchAll();
    }

    @Override
    public M getById(I id) {
        repository.setEntityClass(getEntityClass());
        return super.getById(id);
    }

    @Override
    public M searchOne(Where where) {
        repository.setEntityClass(getEntityClass());
        return super.searchOne(where);
    }

    @Override
    public SearchPageResult<M> searchPage(int page, int limit) {
        repository.setEntityClass(getEntityClass());
        return super.searchPage(page, limit);
    }
}
